package com.serve.oa.listener;

import cn.hutool.core.util.ArrayUtil;
import com.serve.oa.service.ComOrganizationService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

@Component
public class ManagerTaskHandler implements TaskListener {


    @Autowired
    private ComOrganizationService comOrganizationService;

    private static ManagerTaskHandler myListener;

    @PostConstruct
    public void init() {
        myListener = this;
        myListener.comOrganizationService = this.comOrganizationService;
    }



    @Override
    public void notify(DelegateTask delegateTask) {



        Map map = delegateTask.getVariables();
     //   //System.out.println(map.get("fqr").toString()+"213122");
        List<Integer> user = myListener.comOrganizationService.gerManUserByuserId(map.get("fqr").toString());

                if(!user.isEmpty()){

                    for(Integer map2 : user){
                        delegateTask.addCandidateUser(String.valueOf(map2));
                    }
                }


    }


}
